﻿using System;
using System.Data;

namespace FluentSql
{
    public abstract class BaseFluentSqlCommand
    {
        #region Public Constructors

        public BaseFluentSqlCommand()
        {
            IsolationLevel = IsolationLevel.ReadCommitted;
            CommandType = CommandType.StoredProcedure;
            KeepConnection = true;
        }

        #endregion Public Constructors

        #region Public Properties

        public string Command { get; set; }

        public CommandType CommandType { get; set; }

        public IDalContext Context { get; set; }

        public IsolationLevel IsolationLevel { get; set; }

        public bool KeepConnection { get; set; }

        public Action<IDalSqlCommand> SerializeParameters { get; set; }

        #endregion Public Properties

        #region Public Methods

        protected void SetCommandImpl(string iCommand)
        {
            Command = iCommand;
        }

        protected void SetCommandTypeImpl(CommandType iCommandType)
        {
            CommandType = iCommandType;
        }

        protected void SetContextImpl(IDalContext iContext)
        {
            Context = iContext;
        }

        protected void SetIsolationLevelImpl(IsolationLevel iIsolationLevel)
        {
            IsolationLevel = iIsolationLevel;
        }

        protected void SetKeepConnectionImpl(bool iKeepConnection)
        {
            KeepConnection = iKeepConnection;
        }

        protected void SetParametersImpl(Action<IDalSqlCommand> iSerializeParameters)
        {
            SerializeParameters = iSerializeParameters;
        }

        #endregion Public Methods
    }
}
